import express from 'express'
const router = express.Router()

router.post('/login', async (req, res) => {
  const { username, password } = req.body
  console.log('login', username, password)
  try {
    // 这里应该添加实际的用户验证逻辑
    if (username === 'admin' && password === '123456') {
        console.log('login success')
      res.json({
        code: 200,
        data: {
          userInfo: {
            username,
            role: 'admin'
          }
        },
        message: '登录成功'
      })

    } else {
      res.status(401).json({
        code: 401,
        message: '用户名或密码错误'
      })
    }
  } catch (error) {
    console.log(error)
    res.status(500).json({
      code: 500,
      message: '服务器错误'
    })
  }
})

export default router